package nciae.db.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import nciae.db.pojo.entity.Classs;
import nciae.db.pojo.vo.ClassVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

@Mapper
public interface ClassMapper extends BaseMapper<Classs> {

    long countClassesByProjectDateRange(String className, String chargerName, Date startDate, Date endDate);

    //List<ClassVO> selectClassesByProjectDateRange(String className, String chargerName, Date startDate, Date endDate, int offset, Integer size);

    List<ClassVO> selectClassesByProjectDateRange(String className, String chargerName, Date startDate, Date endDate, int offset, Integer size);

    @Update("UPDATE class c SET c.num = (SELECT COUNT(*) FROM student s WHERE s.class_id = c.id) WHERE c.id = #{id};")
    void refreshClassSize(Integer id);

}
